var templateColumnConfig = {
  purchaseColumns: [{
    label: '序号',
    field: 'index',
    noUsedSort: true
  }, {
    label: '订单编号',
    field: 'companyOrderId',
    align: 'left'
  }, {
    label: '工厂型号',
    field: 'factoryNo',
    align: 'left'
  }, {
    label: '客户型号',
    field: 'articleNo',
    align: 'left'
  }, {
    label: '物料名称',
    field: 'materialName',
    align: 'left'
  }, {
    label: '供方编号',
    field: 'providerNo',
    align: 'left'
  }, {
    label: '描述',
    field: 'colorDescription',
    align: 'left'
  }, {
    label: '编号',
    field: 'color',
    align: 'left'
  }, {
    label: '规格',
    field: 'model',
    align: 'left'
  }, {
    label: '材质',
    field: 'qualityType',
    align: 'left'
  }, {
    label: '透光率(%)',
    field: 'transmittance',
    align: 'center'
  }, {
    label: '物料部门',
    field: 'materialDeptName',
    align: 'center'
  }, {
    label: '采购量(带单位)',
    field: 'purchaseCount-unit',
    funName: function (order) {
      return `${order.purchaseCount}${order.unit}`;
    },
    sortField: 'purchaseCount'
  }, {
    label: '采购量',
    field: 'purchaseCount'
  }, {
    label: '单位',
    field: 'unit'
  }, {
    label: '单价',
    field: 'price'
  }, {
    label: '金额',
    field: 'totalMoney'
  }, {
    label: '备注',
    field: 'remark',
    align: 'left',
    edit: true,
    noUsedSort: true
  }],

  prePurchaseColumns: [{
    label: '序号',
    field: 'lineNo',
    type: 'lineNo',
    noUsedSort: true
  }, {
    label: '订单编号',
    field: 'companyOrderId',
    align: 'left'
  }, {
    label: '工厂型号',
    field: 'factoryNo',
    align: 'left'
  }, {
    label: '物料名称',
    field: 'materialName',
    align: 'left'
  }, {
    label: '供方编号',
    field: 'providerNo',
    align: 'left'
  }, {
    label: '描述',
    field: 'colorDescription',
    align: 'left'
  }, {
    label: '编号',
    field: 'color',
    align: 'left'
  }, {
    label: '规格',
    field: 'model',
    align: 'left'
  }, {
    label: '采购量(带单位)',
    field: 'purchaseCount-unit',
    funName: function (order) {
      return `${order.purchaseCount}${order.unit}`;
    },
    sortField: 'purchaseCount'
  }, {
    label: '采购量',
    field: 'purchaseCount'
  }, {
    label: '单位',
    field: 'unit'
  }, {
    label: '单价',
    field: 'price'
  }, {
    label: '金额',
    field: 'totalMoney'
  }, {
    label: '备注',
    field: 'remark',
    align: 'left',
    edit: true,
    noUsedSort: true
  }],

  warehouseInoutOrderColumns: [{
    label: '物料名称',
    field: 'materialName',
    align: 'left'
  }, {
    label: '规格型号',
    field: 'model',
    align: 'left'
  }, {
    label: '编号',
    field: 'color',
    align: 'left'
  }, {
    label: '描述',
    field: 'colorDescription',
    align: 'left'
  }, {
    label: '订单编号',
    field: 'companyOrderId',
    align: 'left'
  }, {
    label: '工厂型号',
    field: 'factoryNo',
    align: 'left'
  }, {
    label: '客户型号',
    field: 'customerNo',
    align: 'left'
  }, {
    label: '入库数',
    field: 'purchaseCount'
  }, {
    label: '数量',
    field: 'count'
  }, {
    label: '单位',
    field: 'inOutUnit'
  }, {
    label: '单价',
    field: 'inCountPrice'
  }, {
    label: '金额',
    field: 'totalPrice'
  }, {
    label: '供应商',
    field: 'providerName',
    align: 'left'
  }, {
    label: '交接数',
    field: 'selfOutFuCount'
  }, {
    label: '备注',
    field: 'remark',
    align: 'left',
    noUsedSort: true
  }],

  warehouseInOrderColumns: [{
    label: '物料名称',
    field: 'materialName',
    align: 'left'
  }, {
    label: '订单编号',
    field: 'companyOrderId',
    align: 'left'
  }, {
    label: '工厂型号',
    field: 'factoryNo',
    align: 'left'
  }, {
    label: '客户型号',
    field: 'customerNo',
    align: 'left'
  }, {
    label: '规格型号',
    field: 'model',
    align: 'left'
  }, {
    label: '编号',
    field: 'color',
    align: 'left'
  }, {
    label: '描述',
    field: 'colorDescription',
    align: 'left'
  }, {
    label: '数量',
    field: 'inCount'
  }, {
    label: '结算数量',
    field: 'count'
  }, {
    label: '单位',
    field: 'inOutUnit'
  }, {
    label: '单价',
    field: 'inCountPrice'
  }, {
    label: '金额',
    field: 'totalPrice'
  }, {
    label: '供应商',
    field: 'providerName',
    align: 'left'
  }, {
    label: '交接数',
    field: 'selfOutFuCount'
  }, {
    label: '备注',
    field: 'remark',
    align: 'left',
    noUsedSort: true
  }],

  productWarehouseInoutOrderColumns: [{
    label: '描述',
    field: 'colorDescription',
    align: 'left'
  }, {
    label: '订单编号',
    field: 'companyOrderId',
    align: 'left'
  }, {
    label: '工厂型号',
    field: 'factoryNo',
    align: 'left'
  }, {
    label: '客户型号',
    field: 'customerNo',
    align: 'left'
  }, {
    label: '数量',
    field: 'count'
  }, {
    label: '单位',
    field: 'inOutUnit'
  }, {
    label: '单价',
    field: 'inCountPrice'
  }, {
    label: '金额',
    field: 'totalPrice'
  }, {
    label: '供应商',
    field: 'providerName',
    align: 'left'
  }, {
    label: '交接数',
    field: 'selfOutFuCount'
  }, {
    label: '备注',
    field: 'remark',
    align: 'left',
    noUsedSort: true
  }],

  productWarehouseInOrderColumns: [{
    label: '描述',
    field: 'colorDescription',
    align: 'left'
  }, {
    label: '订单编号',
    field: 'companyOrderId',
    align: 'left'
  }, {
    label: '工厂型号',
    field: 'factoryNo',
    align: 'left'
  }, {
    label: '客户型号',
    field: 'customerNo',
    align: 'left'
  }, {
    label: '数量',
    field: 'count'
  }, {
    label: '单位',
    field: 'inOutUnit'
  }, {
    label: '单价',
    field: 'inCountPrice'
  }, {
    label: '金额',
    field: 'totalPrice'
  }, {
    label: '供应商',
    field: 'providerName',
    align: 'left'
  }, {
    label: '交接数',
    field: 'selfOutFuCount'
  }, {
    label: '备注',
    field: 'remark',
    align: 'left',
    noUsedSort: true
  }],

  outOrderColumns: [{
    label: '订单编号',
    field: 'companyOrderId',
    align: 'left'
  }, {
    label: '工厂型号',
    field: 'factoryId',
    align: 'left'
  }, {
    label: '客户型号',
    field: 'coustomId',
    align: 'left'
  }, {
    label: '客户订单号',
    field: 'coustomOrderId',
    align: 'left'
  }, {
    label: '供应商',
    field: 'supplierName',
    align: 'left'
  }, {
    label: '加工工艺',
    field: 'technology',
    align: 'left'
  }, {
    label: '流程周期',
    field: 'flowCycle'
  }, {
    label: '加工对象',
    field: 'maching'
  }, {
    label: '颜色',
    field: 'color',
    align: 'left'
  }, {
    label: '规格',
    field: 'model',
    align: 'left'
  }, {
    label: '外协数量',
    field: 'count'
  }, {
    label: '单价',
    field: 'unitPrice'
  }, {
    label: '计价数量',
    field: 'valuationCount'
  }, {
    label: '计价数量(带单位)',
    field: 'valuationCount-unit',
    funName: function (warehouse) {
      return `${warehouse.valuationCount}${warehouse.valuationUint}`;
    },
    sortField: 'valuationCount'
  }, {
    label: '合计',
    field: 'totalPrice'
  }, {
    label: '备注',
    field: 'remark',
    align: 'left',
    edit: true,
    noUsedSort: true
  }, {
    label: '完成时间',
    field: 'returenTime',
    funName: function (warehouse) {
      return SysUtil.formatDate2String(warehouse.returenTime, 'MM-DD');
    }
  }, {
    label: '完成数量',
    field: 'returnCount'
  }, {
    label: '完成计价数量',
    field: 'returnValuationCount'
  }, {
    label: '完成计价数量',
    field: 'returnValuationCount-unit',
    funName: function (warehouse) {
      return `${warehouse.returnValuationCount}${warehouse.valuationUint}`;
    },
    sortField: 'returnValuationCount'
  }, {
    label: '制单时间',
    field: 'finishTime',
    funName: function (warehouse) {
      return SysUtil.formatDate2String(warehouse.finishTime, 'MM-DD');
    },
    sortField: 'finishTime'
  }, {
    label: '制单人',
    field: 'createUser',
    align: 'left'
  }, {
    label: '制单时间',
    field: 'createTime',
    funName: function (warehouse) {
      return SysUtil.formatDate2String(warehouse.createTime, 'MM-DD');
    },
    sortField: 'createTime'
  }, {
    label: '审核人',
    field: 'approvalUser',
    align: 'left'
  }, {
    label: '审核时间',
    field: 'approvalTime',
    funName: function (warehouse) {
      return SysUtil.formatDate2String(warehouse.approvalTime, 'MM-DD');
    },
    sortField: 'approvalTime'
  }],

  issueOrderColumns: [{
    label: '订单编号',
    field: 'companyOrderId',
    align: 'left'
  }, {
    label: '工厂型号',
    field: 'factoryNo',
    align: 'left'
  }, {
    label: '客户型号',
    field: 'customerNo',
    align: 'left'
  }, {
    label: '供应商',
    field: 'providerName',
    align: 'left'
  }, {
    label: '物料名称',
    field: 'materialName',
    align: 'left'
  }, {
    label: '规格',
    field: 'model',
    align: 'left'
  }, {
    label: '编号',
    field: 'color',
    align: 'left'
  }, {
    label: '描述',
    field: 'colorDescription',
    align: 'left'
  }, {
    label: '数量',
    field: 'count'
  }, {
    label: '供方编号',
    field: 'providerNo',
    align: 'left'
  }, {
    label: '制单人',
    field: 'createUser',
    align: 'left'
  }, {
    label: '制单日期',
    field: 'createTime',
    funName: function (order) {
      return SysUtil.formatDate2String(order.createTime, 'MM-DD');
    },
    sortField: 'createTime'
  }, {
    label: '领料人',
    field: 'pickerPeople',
    align: 'left'
  }, {
    label: '备注',
    field: 'remark',
    align: 'left',
    edit: true,
    noUsedSort: true
  }],
  returnOrderColumns: [{
    label: '行号',
    field: 'lineNo',
    type: 'lineNo',
    align: 'center',
    noUsedSort: true
  }, {
    label: '订单编号',
    field: 'companyOrderId',
    align: 'left'
  }, {
    label: '工厂型号',
    field: 'factoryNo',
    align: 'left'
  }, {
    label: '客户型号',
    field: 'customerNo',
    align: 'left'
  }, {
    label: '供应商',
    field: 'providerName',
    align: 'left'
  }, {
    label: '物料名称',
    field: 'materialName',
    align: 'left'
  }, {
    label: '编号',
    field: 'color',
    align: 'left'
  }, {
    label: '描述',
    field: 'colorDescription',
    align: 'left'
  }, {
    label: '规格',
    field: 'model',
    align: 'left'
  }, {
    label: '物料部门',
    field: 'materialDeptName',
    align: 'left'
  }, {
    label: '退回单位',
    field: 'inOutUnit',
    align: 'center'
  }, {
    label: '退回单价',
    field: 'inCountPrice',
    align: 'center'
  }, {
    label: '退回数量',
    field: 'count',
    align: 'center'
  }, {
    label: '退回结算数量',
    field: 'sumMoneyCount',
    align: 'center'
  }, {
    label: '退回金额',
    field: 'returnMoney',
    align: 'center'
  }, {
    label: '备注',
    field: 'remark',
    align: 'left',
    edit: true,
    noUsedSort: true
  }]
};

var defaultTemplateColumnConfig = {
  purchaseColumns: [{
    label: '序号',
    field: 'index',
    width: 40
  }, {
    label: '订单编号',
    field: 'companyOrderId',
    width: 125,
    hasSort: true,
    orderType: 1
  }, {
    label: '工厂型号',
    field: 'factoryNo',
    width: 80,
    hasSort: true,
    orderType: 1
  }, {
    label: '物料名称',
    field: 'materialName',
    width: 100,
    hasSort: true
  }, {
    label: '描述',
    field: 'colorDescription',
    width: 100,
    hasSort: true
  }, {
    label: '编号',
    field: 'color',
    width: 100,
    hasSort: true
  }, {
    label: '规格',
    field: 'model',
    width: 60,
    hasSort: true
  }, {
    label: '采购量',
    field: 'purchaseCount-unit',
    width: 70,
    hasSort: true
  }, {
    label: '备注',
    field: 'remark',
    width: 110
  }],

  prePurchaseColumns: [{
    label: '序号',
    field: 'lineNo',
    width: 40
  }, {
    label: '订单编号',
    field: 'companyOrderId',
    width: 125,
    hasSort: true
  }, {
    label: '工厂型号',
    field: 'factoryNo',
    width: 80,
    hasSort: true
  }, {
    label: '物料名称',
    field: 'materialName',
    width: 100,
    hasSort: true
  }, {
    label: '描述',
    field: 'colorDescription',
    width: 100,
    hasSort: true
  }, {
    label: '编号',
    field: 'color',
    width: 100,
    hasSort: true
  }, {
    label: '规格',
    field: 'model',
    width: 60,
    hasSort: true
  }, {
    label: '采购量',
    field: 'purchaseCount-unit',
    width: 70,
    hasSort: true
  }, {
    label: '备注',
    field: 'remark',
    width: 110
  }],

  warehouseInoutOrderColumns: [{
    label: '物料名称',
    field: 'materialName',
    width: 100,
    hasSort: true
  }, {
    label: '规格型号',
    field: 'model',
    width: 80,
    hasSort: true
  }, {
    label: '编号',
    field: 'color',
    width: 100,
    hasSort: true
  }, {
    label: '描述',
    field: 'colorDescription',
    width: 100,
    hasSort: true
  }, {
    label: '工厂型号',
    field: 'factoryNo',
    width: 80,
    hasSort: true
  }, {
    label: '客户型号',
    field: 'customerNo',
    width: 80,
    hasSort: true
  }, {
    label: '出库数量',
    field: 'count',
    width: 70,
    hasSort: true
  }, {
    label: '出库单位',
    field: 'inOutUnit',
    width: 60,
    hasSort: true
  }, {
    label: '出库单价',
    field: 'inCountPrice',
    width: 70,
    hasSort: true
  }, {
    label: '金额',
    field: 'totalPrice',
    width: 70,
    hasSort: true
  }, {
    label: '备注',
    field: 'remark',
    width: 110
  }],

  warehouseInOrderColumns: [{
    label: '物料名称',
    field: 'materialName',
    width: 100,
    hasSort: true
  }, {
    label: '规格型号',
    field: 'model',
    width: 80,
    hasSort: true
  }, {
    label: '编号',
    field: 'color',
    width: 100,
    hasSort: true
  }, {
    label: '描述',
    field: 'colorDescription',
    width: 100,
    hasSort: true
  }, {
    label: '入库数量',
    field: 'inCount',
    width: 70,
    hasSort: true
  }, {
    label: '结算数量',
    field: 'count',
    width: 70,
    hasSort: true
  }, {
    label: '入库单位',
    field: 'inOutUnit',
    width: 60,
    hasSort: true
  }, {
    label: '入库单价',
    field: 'inCountPrice',
    width: 70,
    hasSort: true
  }, {
    label: '金额',
    field: 'totalPrice',
    width: 70,
    hasSort: true
  }, {
    label: '备注',
    field: 'remark',
    width: 110
  }],

  productWarehouseInoutOrderColumns: [{
    label: '描述',
    field: 'colorDescription',
    width: 100,
    hasSort: true
  }, {
    label: '工厂型号',
    field: 'factoryNo',
    width: 80,
    hasSort: true
  }, {
    label: '客户型号',
    field: 'customerNo',
    width: 80,
    hasSort: true
  }, {
    label: '出库数量',
    field: 'count',
    width: 70,
    hasSort: true
  }, {
    label: '出库单位',
    field: 'inOutUnit',
    width: 60,
    hasSort: true
  }, {
    label: '出库单价',
    field: 'inCountPrice',
    width: 70,
    hasSort: true
  }, {
    label: '金额',
    field: 'totalPrice',
    width: 70,
    hasSort: true
  }, {
    label: '备注',
    field: 'remark',
    width: 110
  }],

  productWarehouseInOrderColumns: [{
    label: '描述',
    field: 'colorDescription',
    width: 100,
    hasSort: true
  }, {
    label: '工厂型号',
    field: 'factoryNo',
    width: 80,
    hasSort: true
  }, {
    label: '客户型号',
    field: 'customerNo',
    width: 80,
    hasSort: true
  }, {
    label: '入库数量',
    field: 'count',
    width: 70,
    hasSort: true
  }, {
    label: '入库单位',
    field: 'inOutUnit',
    width: 60,
    hasSort: true
  }, {
    label: '入库单价',
    field: 'inCountPrice',
    width: 70,
    hasSort: true
  }, {
    label: '金额',
    field: 'totalPrice',
    width: 70,
    hasSort: true
  }, {
    label: '备注',
    field: 'remark',
    width: 110
  }],

  outOrderColumns: [{
    label: '订单编号',
    field: 'companyOrderId',
    width: 125,
    hasSort: true
  }, {
    label: '客户订单号',
    field: 'coustomOrderId',
    width: 95,
    hasSort: true
  }, {
    label: '工厂型号',
    field: 'factoryId',
    width: 95,
    hasSort: true
  }, {
    label: '供应商',
    field: 'supplierName',
    width: 100,
    hasSort: true
  }, {
    label: '加工工艺',
    field: 'technology',
    width: 100,
    hasSort: true
  }, {
    label: '加工对象',
    field: 'maching',
    width: 90,
    hasSort: true
  }, {
    label: '颜色',
    field: 'color',
    width: 110,
    hasSort: true
  }, {
    label: '单价',
    field: 'unitPrice',
    width: 70,
    hasSort: true
  }, {
    label: '外协数量',
    field: 'count',
    width: 75,
    hasSort: true
  }, {
    label: '制单时间',
    field: 'createTime',
    width: 65,
    hasSort: true
  }, {
    label: '完成时间',
    field: 'finishTime',
    width: 65,
    hasSort: true
  }, {
    label: '备注',
    field: 'remark',
    width: 80
  }],

  issueOrderColumns: [{
    label: '订单编号',
    field: 'companyOrderId',
    width: 125,
    hasSort: true
  }, {
    label: '工厂型号',
    field: 'factoryNo',
    width: 95,
    hasSort: true
  }, {
    label: '物料名称',
    field: 'materialName',
    width: 100,
    hasSort: true
  }, {
    label: '规格',
    field: 'model',
    width: 80,
    hasSort: true
  }, {
    label: '编号',
    field: 'color',
    width: 100,
    hasSort: true
  }, {
    label: '数量',
    field: 'count',
    width: 75,
    hasSort: true
  }, {
    label: '领料人',
    field: 'pickerPeople',
    width: 100,
    hasSort: true
  }, {
    label: '备注',
    field: 'remark',
    width: 110
  }],
  returnOrderColumns: [{
    label: '行号',
    field: 'lineNo',
    type: 'lineNo',
    width: 50
  }, {
    label: '商品编号',
    field: 'color',
    width: 100,
    hasSort: true
  }, {
    label: '商品名称',
    field: 'materialName',
    width: 100,
    hasSort: true
  }, {
    label: '规格',
    field: 'model',
    width: 100,
    hasSort: true
  }, {
    label: '单位',
    field: 'inOutUnit',
    width: 60,
    hasSort: true
  }, {
    label: '数量',
    field: 'count',
    width: 90,
    hasSort: true
  }, {
    label: '单价',
    field: 'inCountPrice',
    width: 90,
    hasSort: true
  }, {
    label: '含税金额',
    field: 'returnMoney',
    width: 90,
    hasSort: true
  }, {
    label: '备注',
    field: 'remark',
    width: 100
  }]
};

var TemplateColumnConfigUtil = {
  getTemplateColumn(type, hasObj) {
    var columns = null;
    if (type === 'orderPurchaseColumns' || type === 'warehousePurchaseColumns') {
      columns = _.cloneDeep(templateColumnConfig.purchaseColumns);
      if (type === 'warehousePurchaseColumns') {
        columns = _.filter(columns, function (column) {
          return column.orderType !== 1;
        });
      }
    } else {
      columns = templateColumnConfig[type];
    }

    if (columns === undefined) {
      return null;
    }
    columns = _.cloneDeep(columns);
    if (hasObj) {
      var columnObj = {};
      for (var i = 0; i < columns.length; i++) {
        var column = columns[i];
        columnObj[column.field] = column;
      }
      return columnObj;
    }
    return columns;
  },

  getDefaultTemplateColumn(type, hasObj) {
    var columns = null;
    if (type === 'orderPurchaseColumns' || type === 'warehousePurchaseColumns') {
      columns = _.cloneDeep(defaultTemplateColumnConfig.purchaseColumns);
      if (type === 'warehousePurchaseColumns') {
        columns = _.filter(columns, function (column) {
          return column.orderType !== 1;
        });
      }
    } else {
      columns = defaultTemplateColumnConfig[type];
    }
    if (columns === undefined) {
      return null;
    }
    columns = _.cloneDeep(columns);
    if (hasObj) {
      var columnObj = {};
      for (var i = 0; i < columns.length; i++) {
        var column = columns[i];
        columnObj[column.field] = column;
      }
      return columnObj;
    }
    return columns;
  }
};
